<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">

    <ui:define name="title">API配置列表</ui:define>
    <ui:define name="content">
        <h:form>

            <!--菜单 -->
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"
                                         rendered="#{activityListBean.isNormal()}"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         actionListener="#{activityListBean.onReset}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{activityListBean.isNormal()}"/>
                        <p:commandButton icon="fa fa-plus" value="新增"
                                         action="#{activityListBean.onAdd}"
                                         rendered="#{activityListBean.isNormal()}">
                            <f:setPropertyActionListener value="/views/templateConf/activityConf/activitylist.xhtml"
                                                         target="#{currentUserBean.back}"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <!--菜单 -->

            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">

                        <!-- 搜索框 -->
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;">

                                <p:outputLabel for="id" value="模板ID"/>
                                <p:inputText id="id" value="#{activityListBean.$.id}"/>

                                <p:outputLabel for="apiName" value="模板名称"/>
                                <p:inputText id="apiName" value="#{activityListBean.$.apiName}"/>

                                <p:outputLabel for="thirdId" value="甲方ID"/>
                                <p:inputText id="thirdId" value="#{activityListBean.$.thirdId}"/>

                                <p:outputLabel for="thirdName" value="甲方名称"/>
                                <p:inputText id="thirdName" value="#{activityListBean.$.thirdName}"/>
                            </p:panelGrid>
                        </div>
                        <!-- 搜索框 -->

                        <!-- 列表 -->
                        <div class="cad">
                            <p:dataTable id="itemListDataTable"
                                         style="width: 100%"
                                         var="item"
                                         value="#{activityListBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         scrollWidth="100%"
                                         reflow="true"
                                         selection="#{activityListBean.selectedRecords}"
                                         resizableColumns="true">

                                <p:column headerText="操作">
                                    <p:splitButton icon="fa fa-eye"
                                                   action="#{activityListBean.onEdit(item.id)}"
                                                   process="@this">
                                        <f:setPropertyActionListener
                                                value="/views/templateConf/activityConf/activitylist.xhtml"
                                                target="#{currentUserBean.back}"/>
                                        <p:menuitem value="删除" icon="fa fa-remove"
                                                    actionListener="#{activityListBean.onDelete(item.id)}"
                                                    process="@this" update="@form">
                                            <p:confirm header="提示信息" message="是否确定删除?" icon="ui-icon-alert"/>
                                        </p:menuitem>
                                        <p:menuitem value="下线" icon="fa fa-arrow-down"
                                                    actionListener="#{activityListBean.changeStatus(item.id, 0)}"
                                                    process="@this" update="@form" rendered="#{item.status == 1}">
                                        </p:menuitem>
                                        <p:menuitem value="上线" icon="fa fa-arrow-up"
                                                    actionListener="#{activityListBean.changeStatus(item.id, 1)}"
                                                    process="@this" update="@form" rendered="#{item.status == 0}">
                                        </p:menuitem>
                                        <p:menuitem value="复制" icon="ui-icon-arrowrefresh-1-w"
                                                    action="#{activityItemListBean.onCopySave(item.id)}"
                                                    process="@this">
                                            <p:confirm header="提示信息" message="是否确定复制?点击复制保存后生效！" icon="ui-icon-alert"/>
                                        </p:menuitem>
                                    </p:splitButton>
                                </p:column>
                                <p:column headerText="模板ID" width="5%">
                                    <h:outputText value="#{item.id}"/>
                                </p:column>
                                <p:column headerText="模板名称">
                                    <h:outputText value="#{item.apiName}"/>
                                </p:column>
                                <p:column headerText="甲方ID" width="5%">
                                    <h:outputText value="#{item.thirdId}"/>
                                </p:column>
                                <p:column headerText="甲方名称">
                                    <h:outputText value="#{item.thirdName == '' ? '非API' : item.thirdName}"/>
                                </p:column>
                                <p:column headerText="状态" width="5%">
                                    <h:outputText value="#{item.status == '1' ? '上线' : '下线'}"/>
                                </p:column>
                                <p:column headerText="操作人">
                                    <h:outputText value="#{item.userName}"/>
                                </p:column>
                                <p:column headerText="操作时间">
                                    <h:outputText value="#{item.uptime}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                        <!-- 列表 -->

                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>